import java.util.Enumeration;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;

public class CommonBean extends HashMap<String, String> {
	private static final long serialVersionUID = 1L;
	
	private HashMap<String,String> request = new HashMap<String,String>();
	public String error = "";
	
	/**
	 * Populates the bean with data from the request.
	 * @param request
	 * @param bean		bean to populate
	 */
	@SuppressWarnings("unchecked")
	public void populate(HttpServletRequest request, CommonBean bean){
		System.out.println("AbstractBean.populate()");
		/* HashMap<String,String> temp = new HashMap<String,String>(); */
		
		Enumeration enumeration = request.getParameterNames();
		if (enumeration != null) {
			while (enumeration.hasMoreElements()) {
				String paramName = (String)enumeration.nextElement();
				String paramValue = request.getParameter(paramName);
				paramValue = paramValue.trim();
				//temp.put(paramName, paramValue);
				bean.put(paramName, paramValue);
				System.out.println(paramName + "|||" + paramValue);
			}
		}
		
		/* this.request = temp; */
	}
	
	public String getRequest(String name) {
		if(request.get(name) == null) {
			return "";
		}
		return request.get(name);
	}
	
	public String getError() {
		return this.error;
	}
}